﻿//using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace AiMachineControl.Model
{
    /// <summary>
    /// Soket通讯消息体
    /// </summary>
    [Serializable]
    public class SoketMessage
    {
        /// <summary>
        /// 客户端ID,算力机ID
        /// </summary>
        public string SendClientId { get; set; }
        /// <summary>
        /// 通知动作(客户端发送消息用：项目启动:200,项目关闭:500,心跳包通知:99,维护中:301,维护结束:302,拆包完成:333,视频推理完成:444,视频合成完成:222)
        /// </summary>
        public int Action { get; set; }
        /// <summary>
        /// 算力机状态码(服务端发送消息用：准备:88,结束:44,心跳包通知:99,指定项目更新:77,音频拆包:33,视频合成:22)
        /// </summary>
        public int StatusCode { get; set; }
        /// <summary>
        /// 消息说明
        /// </summary>
        public string Message { get; set; }
        /// <summary>
        /// 使用记录ID
        /// </summary>
        public int UseLogId { get; set; } = 0;
        /// <summary>
        /// 附加信息
        /// 根据处理任务不同携带不同数据体
        /// </summary>
        public object Data { get; set; }
    }

    [JsonSerializable(typeof(SoketMessage), GenerationMode = JsonSourceGenerationMode.Metadata)]
    internal partial class MetadataOnlySoketMessageOnlyContext : JsonSerializerContext
    {
    }

    #region Ai项目信息
    /// <summary>
    /// Ai项目信息
    /// </summary>
    public class AiProjectInfo
    {
        //[JsonConstructor]
        //internal AiProjectInfo() { }
        /// <summary>
        /// 算力机类型
        /// </summary>
        public int Type { get; set; }
        /// <summary>
        /// 项目名称
        /// </summary>
        public string ProName { get; set; }
        /// <summary>
        /// 项目版本号
        /// </summary>
        public string VersionCode { get; set; }
        /// <summary>
        /// 是否初次使用
        /// </summary>
        public bool IsFirst { get; set; }
        /// <summary>
        /// 是否离线渲染
        /// </summary>
        public bool IsOffline { get; set; }
        /// <summary>
        /// 离线渲染详细信息
        /// </summary>
        public OffLineInfo OffLineInfo { get; set; }
    }

    [JsonSerializable(typeof(AiProjectInfo), GenerationMode = JsonSourceGenerationMode.Metadata)]
    internal partial class MetadataOnlyAiProjectInfoOnlyContext : JsonSerializerContext
    {
    } 
    #endregion

    #region 离线渲染
    /// <summary>
    /// 离线渲染信息
    /// </summary>
    public class OffLineInfo
    {
        /// <summary>
        /// 数字人结果ID
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 模型类型
        /// </summary>
        public int Type { get; set; }
        /// <summary>
        /// 模型名字
        /// </summary>
        public string ModelName { get; set; }
        /// <summary>
        /// 推理模型文件夹名字
        /// </summary>
        public string TrialFolder { get; set; }
        /// <summary>
        /// 推理结果名字，需要带后缀
        /// </summary>
        public string ResultName { get; set; }
        /// <summary>
        /// 素材地址
        /// </summary>
        public string FileAddress { get; set; }
        /// <summary>
        /// 文件下标
        /// </summary>
        public int Index { get;set; }
    }

    [JsonSerializable(typeof(OffLineInfo), GenerationMode = JsonSourceGenerationMode.Metadata)]
    internal partial class MetadataOnlyOffLineInfoInfoOnlyContext : JsonSerializerContext
    {
    }
    #endregion

    #region 离线推理回传类
    /// <summary>
    /// 离线渲染回调
    /// </summary>
    [Serializable]
    public class OffLineReback
    {
        /// <summary>
        /// 数字人表ID
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// Npy文件下标
        /// </summary>
        public int Index { get; set; }
        /// <summary>
        /// 推理后视频地址
        /// </summary>
        public string FilePath { get; set; }

    }
    [JsonSerializable(typeof(OffLineReback), GenerationMode = JsonSourceGenerationMode.Metadata)]
    internal partial class MetadataOnlyOffLineRebackOnlyContext : JsonSerializerContext
    {
    }
    #endregion

    #region 音频拆分
    /// <summary>
    /// 音频数据
    /// </summary>
    public class VoiceInfo
    {
        /// <summary>
        /// 数字人Id
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 模型名
        /// </summary>
        public string ModelName { get; set; }
        /// <summary>
        /// wav音频文件数据
        /// </summary>
        public string FileAdd { get; set; }
        /// <summary>
        /// 拆分后文件地址集合
        /// </summary>
        public List<string> NpyList { get; set; }
    }
    [JsonSerializable(typeof(VoiceInfo), GenerationMode = JsonSourceGenerationMode.Metadata)]
    internal partial class MetadataOnlyVoiceInfoOnlyContext : JsonSerializerContext
    {
    }
    #endregion

    #region 视频合成
    /// <summary>
    /// 视频合成类
    /// </summary>
    public class VideoCombine
    {
        /// <summary>
        /// 任务标识
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 视频排序下标
        /// </summary>
        public int Index { get; set; }
        /// <summary>
        /// 模型名字
        /// </summary>
        public string proName { get; set; }
        /// <summary>
        /// 合成类型(0:替换绿幕为背景图,1:合成数字人至背景图，2：合成数字人至视频)
        /// </summary>
        public int Type { get; set; }
        /// <summary>
        /// 文件一(背景图或背景视频)
        /// </summary>
        public string FileOne { get; set; }
        /// <summary>
        /// 文件二，待处理数字人
        /// </summary>
        public string FileTwo { get; set; }
        /// <summary>
        /// 文件一分辨率
        /// </summary>
        public string OneFBL { get; set; }
        /// <summary>
        /// 文件2分辨率
        /// </summary>
        public string TwoFBL { get; set; }
        /// <summary>
        /// 左间距
        /// </summary>
        public string Left { get; set; }
        /// <summary>
        /// 上间距
        /// </summary>
        public string Top { get; set; }
    }
    [JsonSerializable(typeof(VideoCombine), GenerationMode = JsonSourceGenerationMode.Metadata)]
    internal partial class MetadataOnlyVideoCombineOnlyContext : JsonSerializerContext
    {
    }
    #endregion

    #region 返回结果信息
    /// <summary>
    /// 返回结果信息
    /// </summary>
    public class ReturnMsgModel
    {
        public bool status { get; set; }
        public int code { get; set; }
        public string msg { get; set; }
        public string data { get; set; }
    }
    #endregion
}
